package cn.net.yugu.doraemon.netty.protocol.msg08;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 后面可能会出现新的心跳版本 为了兼容新的版本 这里统一做一个转换
 */
@Data
public class HeartParam implements Serializable{

    public static final String EMPTY_BATTERY_CARD = "00000000";
    public static final String EMPTY_IMEI_CODE = "000000000000000";
    public static final String EMPTY_CHARGER_CODE = "000000";

    //请求参数
    public Integer serial;
    public String code;
    public String version;
    /** 换电柜温度1     */
    public Integer temp1;
    /**换电柜温度2*/
    public Integer temp2;
    public Integer degree;
    public Byte network;
    public Byte signal;
    public Byte fireState;
    public Byte peripheral;
    //
    public Byte fanSpeed;
    public Byte waterLevel;
    public Byte smokeState;

    public Integer acVoltage;
    public Long reportTime;

    public Integer boxSize;

    public List<Box> boxList = new ArrayList<Box>(20);

    /**
     * 柜子电表ID（当前一个换电柜仅一个电表）
     */
    private String electricMeterId;

    /**
     * 换电柜子温度3（20格口柜子的第三个温度传感器）
     */
    private int temp3;

    public void addBox(Box box){
        if (this.boxList == null) {
            this.boxList = new ArrayList<Box>(20);
        }
        this.boxList.add(box);
    }

    @Data
    public static class Box implements Serializable {
        public byte boxNum;
        public Byte isClosed;
        public int boxState;
        public int boxState2;
        public Integer fault;
        public Integer nfc;
        public Integer charge;
        public Byte isSmokeAlarm;
        public Integer boxStatus; //格口状态 1 电池入柜 2 电池一直在箱子中 3 电池被取出
        public Integer work; //业务状态 1 电池入柜 2 电池一直在箱子中 3 电池被取出
        public Byte cabinetFault; //1 柜子通讯异常 2 电池锁定异常 3 非法打开
        public String orderId;
        public String backOrderId;

        public String batteryId;
        public String batteryCode;
        public String batteryVersion;
        public Integer voltage;
        public Integer electricity;
        public int restCapacity;
        public Byte volume;
        public int circle;
        public int ratedCapacity;
        public String temp;
        public Integer serials;
        public String singleVoltage;
        public Integer protectState;
        public Byte fet;
        public int linkStatus;
        public Byte chargeStatus;
        public Integer power;
        public Integer energy;
        public Integer batteryTemp1;
        public Integer batteryTemp2;
        public Integer batteryIsNormal;
        public Integer serial;


        public Byte boxVersion;
        public Integer boxTemp;
        public Byte fanSpeed;
        public String oldBatteryId;
        public Integer openCellType;
        public Integer limitFlag;
        public Integer closeError;

        //充电器
        public String chargerVersion;
        public String chargerModule;
        public Integer chargeState;
        public Integer chargeStage;
        public Integer chargeTime;
        public Integer chargeVoltage;
        public Integer batteryVoltage;
        public Integer chargeCurrent;
        public Integer transformerTemperature;
        public Integer heatsinkTemperature;
        public Integer ambientTemperature;
        public Integer chargerFault;
        public Integer enableCharge;

        //格口是否禁用
        public Integer boxForbidden;//1禁用 0启用

        public Integer unknownFlag;
        public Integer fault41Flag;
        public Long openTime;
    }

}
